package common

import (
	"fmt"
	"io"
	"net/http"
	"strconv"
)

func HttpGet(url string) (string, error) {
	resp, err := http.Get(url)
	if err != nil {
		fmt.Println("<HttpGet> http request err:", err)
		return "", err
	}
	defer resp.Body.Close()
	body, err := io.ReadAll(resp.Body)
	if err != nil {
		fmt.Println("<HttpGet> http response err", err)
		return "", err
	}
	fmt.Println("<HttpGet> reponse body :", string(body))
	return string(body), nil
}

func SendGroupMessage(group_id, message string, auto_escape bool) {
	postUrl := "0.0.0.0:5701/send_group_msg?group_id=" + group_id + "&message=" + message + "&auto_escape=" + strconv.FormatBool(auto_escape)
	_, _ = HttpGet(postUrl)
}

//func HttpPost(url string,)
